package com.lucenly.card.view.dialog;

import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.lucenly.card.R;

public class TixianDialog extends Dialog{
    public TixianDialog(@NonNull Context context,int type) { //0成功  1失败
        super(context, R.style.alert_dialog);
        setContentView(R.layout.dialog_tixian);
        ImageView iv_guanbi = findViewById(R.id.iv_guanbi);
        TextView tv_title = findViewById(R.id.tv_title);
        ImageView imageView = findViewById(R.id.iv_img);
        if(type==0){
            imageView.setImageResource(R.mipmap.tixianchenggong_anniu2x);
            tv_title.setText("提现成功");
        }else{
            imageView.setImageResource(R.mipmap.tixianshibai_bg2x);
            tv_title.setText("提现失败");
        }
        iv_guanbi.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });
        initView(context);
    }

    private void initView(Context context) {
        LinearLayout lLayout_bg = (LinearLayout) findViewById(R.id.lLayout_bg);
        WindowManager windowManager = (WindowManager) context
                .getSystemService(Context.WINDOW_SERVICE);
        Display display = windowManager.getDefaultDisplay();
        setCanceledOnTouchOutside(false);
        // 调整dialog背景大小
        lLayout_bg.setLayoutParams(new FrameLayout.LayoutParams((int) (display
                .getWidth() * 0.8), LinearLayout.LayoutParams.WRAP_CONTENT));
        setCanceledOnTouchOutside(true);
    }
}
